#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int d[N],v[N],a[N],p[N];
int main(){
    freopen("detect.in",r,stdin);
    freopen("detect.out",w,stdout);
    int t;
    cin >> t;
    for(int i=1; i<=t; i++) {
        int n,m,L,V;
        cin >> n >> m >> L >> V;
        for(int j=1; j<=n; j++) {
            cin >> d[i] >> v[i] >> a[i];
        }
        for(int j=1; j<=n; j++) {
            cin >> p[i];
        }
        cout << (n*m-L)/V << m/v ;
    }
    return 0;
}